//
//  ViewController2.m
//  APIdemo
//
//  Created by student on 16/3/29.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController2.h"
#import "NetManager.h"
@interface ViewController2 ()<UITabBarDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITextField *cityname;

@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property(strong,nonnull)NSArray *days;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.    
}
- (IBAction)b1:(id)sender
{
    NSDictionary *dict=[NetManager requestWeatherByCityName:self.cityname.text];
    self.days=dict[@"daily_forecast"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.days.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%@",self.days);
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
//    if(cell == nil)
//    {
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
//    }
    NSDictionary *d=self.days[indexPath.row];
    NSDictionary *dd=d[@"tmp"];
    cell.textLabel.text=[NSString stringWithFormat:@"%@,%@",dd[@"max"],dd[@"min"]];
    return cell;
}

@end
